import { RouteRecordRaw } from "vue-router";
import { getUserMenus } from "@/api/system/menu";

/**
 * 根据后端查询的用户菜单, 生成动态菜单.
 */
export const generatorDynamicRouter = (): Promise<RouteRecordRaw[]> => {
  return new Promise((resolve, reject) => {
    getUserMenus()
      .then((result) => {
        const routeList = result;
        resolve(routeList);
      })
      .catch((error: Error) => {
        reject(error);
      });
  });
};
